package it.maggioni.struts2.actions;

import com.opensymphony.xwork2.Action;

import it.maggioni.struts2.services.TutorialFinderService;

public class BestTutorialFinderAction implements Action {
	
	private String language;
	
	private String bestTutorial;
	private String errMsg;

	public String execute() {
		TutorialFinderService tutorialFinderServices = new TutorialFinderService();
		try {
			setBestTutorial(tutorialFinderServices.getBestTutorial(getLanguage()));
		} catch (Exception e) {
			setErrMsg(e.getMessage());
			return ERROR;
		}
		return SUCCESS;
	}

	public String getBestTutorial() {
		return bestTutorial;
	}

	public void setBestTutorial(String bestTutorial) {
		this.bestTutorial = bestTutorial;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public String getErrMsg() {
		return errMsg;
	}

	public void setErrMsg(String errMsg) {
		this.errMsg = errMsg;
	}
}
